.class public Lcom/snowplowanalytics/snowplow/tracker/Tracker;
.super Ljava/lang/Object;


# static fields
.field private static final TAG:Ljava/lang/String;

.field private static sessionExecutor:Ljava/util/concurrent/ScheduledExecutorService;

.field private static spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;


# instance fields
.field private appId:Ljava/lang/String;

.field private applicationCrash:Z

.field private base64Encoded:Z

.field private final context:Landroid/content/Context;

.field private dataCollection:Ljava/util/concurrent/atomic/AtomicBoolean;

.field private devicePlatform:Lcom/snowplowanalytics/snowplow/tracker/DevicePlatforms;

.field private emitter:Lcom/snowplowanalytics/snowplow/tracker/Emitter;

.field private geoLocationContext:Z

.field private level:Lcom/snowplowanalytics/snowplow/tracker/utils/LogLevel;

.field private lifecycleEvents:Z

.field private mobileContext:Z

.field private namespace:Ljava/lang/String;

.field private sessionCheckInterval:J

.field private sessionContext:Z

.field private subject:Lcom/snowplowanalytics/snowplow/tracker/Subject;

.field private threadCount:I

.field private timeUnit:Ljava/util/concurrent/TimeUnit;

.field private trackerSession:Lcom/snowplowanalytics/snowplow/tracker/Session;

.field private final trackerVersion:Ljava/lang/String;


# direct methods
.method static constructor <clinit>()V
    .locals 2

    const/4 v1, 0x0

    const-class v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->TAG:Ljava/lang/String;

    sput-object v1, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    sput-object v1, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionExecutor:Ljava/util/concurrent/ScheduledExecutorService;

    return-void
.end method

.method private constructor <init>(Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;)V
    .locals 8

    const/4 v0, 0x2

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const-string v1, "andr-0.6.1"

    iput-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->trackerVersion:Ljava/lang/String;

    new-instance v1, Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v2, 0x1

    invoke-direct {v1, v2}, Ljava/util/concurrent/atomic/AtomicBoolean;-><init>(Z)V

    iput-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->dataCollection:Ljava/util/concurrent/atomic/AtomicBoolean;

    iget-object v1, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->context:Landroid/content/Context;

    iput-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->context:Landroid/content/Context;

    iget-object v1, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->emitter:Lcom/snowplowanalytics/snowplow/tracker/Emitter;

    iput-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->emitter:Lcom/snowplowanalytics/snowplow/tracker/Emitter;

    iget-object v1, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->appId:Ljava/lang/String;

    iput-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->appId:Ljava/lang/String;

    iget-boolean v1, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->base64Encoded:Z

    iput-boolean v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->base64Encoded:Z

    iget-object v1, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->namespace:Ljava/lang/String;

    iput-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->namespace:Ljava/lang/String;

    iget-object v1, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->subject:Lcom/snowplowanalytics/snowplow/tracker/Subject;

    iput-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->subject:Lcom/snowplowanalytics/snowplow/tracker/Subject;

    iget-object v1, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->devicePlatform:Lcom/snowplowanalytics/snowplow/tracker/DevicePlatforms;

    iput-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->devicePlatform:Lcom/snowplowanalytics/snowplow/tracker/DevicePlatforms;

    iget-object v1, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->logLevel:Lcom/snowplowanalytics/snowplow/tracker/utils/LogLevel;

    iput-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->level:Lcom/snowplowanalytics/snowplow/tracker/utils/LogLevel;

    iget-boolean v1, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->sessionContext:Z

    iput-boolean v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionContext:Z

    iget-wide v2, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->sessionCheckInterval:J

    iput-wide v2, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionCheckInterval:J

    iget v1, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->threadCount:I

    if-ge v1, v0, :cond_1

    :goto_0
    iput v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->threadCount:I

    iget-object v0, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->timeUnit:Ljava/util/concurrent/TimeUnit;

    iput-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->timeUnit:Ljava/util/concurrent/TimeUnit;

    iget-boolean v0, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->geoLocationContext:Z

    iput-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->geoLocationContext:Z

    iget-boolean v0, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->mobileContext:Z

    iput-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->mobileContext:Z

    iget-boolean v0, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->applicationCrash:Z

    iput-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->applicationCrash:Z

    iget-boolean v0, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->lifecycleEvents:Z

    iput-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->lifecycleEvents:Z

    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionContext:Z

    if-eqz v0, :cond_0

    new-instance v1, Lcom/snowplowanalytics/snowplow/tracker/Session;

    iget-wide v2, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->foregroundTimeout:J

    iget-wide v4, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->backgroundTimeout:J

    iget-object v6, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->timeUnit:Ljava/util/concurrent/TimeUnit;

    iget-object v7, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->context:Landroid/content/Context;

    invoke-direct/range {v1 .. v7}, Lcom/snowplowanalytics/snowplow/tracker/Session;-><init>(JJLjava/util/concurrent/TimeUnit;Landroid/content/Context;)V

    iput-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->trackerSession:Lcom/snowplowanalytics/snowplow/tracker/Session;

    :cond_0
    iget v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->threadCount:I

    invoke-static {v0}, Lcom/snowplowanalytics/snowplow/tracker/Executor;->setThreadCount(I)V

    iget-object v0, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->logLevel:Lcom/snowplowanalytics/snowplow/tracker/utils/LogLevel;

    invoke-static {v0}, Lcom/snowplowanalytics/snowplow/tracker/utils/Logger;->updateLogLevel(Lcom/snowplowanalytics/snowplow/tracker/utils/LogLevel;)V

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->TAG:Ljava/lang/String;

    const-string v1, "Tracker created successfully."

    const/4 v2, 0x0

    new-array v2, v2, [Ljava/lang/Object;

    invoke-static {v0, v1, v2}, Lcom/snowplowanalytics/snowplow/tracker/utils/Logger;->v(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V

    return-void

    :cond_1
    iget v0, p1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;->threadCount:I

    goto :goto_0
.end method

.method synthetic constructor <init>(Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;Lcom/snowplowanalytics/snowplow/tracker/Tracker$1;)V
    .locals 0

    invoke-direct {p0, p1}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;-><init>(Lcom/snowplowanalytics/snowplow/tracker/Tracker$TrackerBuilder;)V

    return-void
.end method

.method static synthetic access$100(Lcom/snowplowanalytics/snowplow/tracker/Tracker;Lcom/snowplowanalytics/snowplow/tracker/payload/TrackerPayload;Ljava/util/List;Ljava/lang/String;)V
    .locals 0

    invoke-direct {p0, p1, p2, p3}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->addEventPayload(Lcom/snowplowanalytics/snowplow/tracker/payload/TrackerPayload;Ljava/util/List;Ljava/lang/String;)V

    return-void
.end method

.method static synthetic access$200(Lcom/snowplowanalytics/snowplow/tracker/Tracker;)Z
    .locals 1

    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->base64Encoded:Z

    return v0
.end method

.method private addEventPayload(Lcom/snowplowanalytics/snowplow/tracker/payload/TrackerPayload;Ljava/util/List;Ljava/lang/String;)V
    .locals 4

    const-string v0, "p"

    iget-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->devicePlatform:Lcom/snowplowanalytics/snowplow/tracker/DevicePlatforms;

    invoke-virtual {v1}, Lcom/snowplowanalytics/snowplow/tracker/DevicePlatforms;->getValue()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {p1, v0, v1}, Lcom/snowplowanalytics/snowplow/tracker/payload/TrackerPayload;->add(Ljava/lang/String;Ljava/lang/String;)V

    const-string v0, "aid"

    iget-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->appId:Ljava/lang/String;

    invoke-virtual {p1, v0, v1}, Lcom/snowplowanalytics/snowplow/tracker/payload/TrackerPayload;->add(Ljava/lang/String;Ljava/lang/String;)V

    const-string v0, "tna"

    iget-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->namespace:Ljava/lang/String;

    invoke-virtual {p1, v0, v1}, Lcom/snowplowanalytics/snowplow/tracker/payload/TrackerPayload;->add(Ljava/lang/String;Ljava/lang/String;)V

    const-string v0, "tv"

    invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    const-string v1, "andr-0.6.1"

    invoke-virtual {p1, v0, v1}, Lcom/snowplowanalytics/snowplow/tracker/payload/TrackerPayload;->add(Ljava/lang/String;Ljava/lang/String;)V

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->subject:Lcom/snowplowanalytics/snowplow/tracker/Subject;

    if-eqz v0, :cond_0

    new-instance v0, Ljava/util/HashMap;

    iget-object v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->subject:Lcom/snowplowanalytics/snowplow/tracker/Subject;

    invoke-virtual {v1}, Lcom/snowplowanalytics/snowplow/tracker/Subject;->getSubject()Ljava/util/Map;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/util/HashMap;-><init>(Ljava/util/Map;)V

    invoke-virtual {p1, v0}, Lcom/snowplowanalytics/snowplow/tracker/payload/TrackerPayload;->addMap(Ljava/util/Map;)V

    :cond_0
    invoke-direct {p0, p2, p3}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->getFinalContext(Ljava/util/List;Ljava/lang/String;)Lcom/snowplowanalytics/snowplow/tracker/payload/SelfDescribingJson;

    move-result-object v0

    if-eqz v0, :cond_1

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/payload/SelfDescribingJson;->getMap()Ljava/util/Map;

    move-result-object v0

    iget-boolean v1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->base64Encoded:Z

    invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v1

    const-string v2, "cx"

    const-string v3, "co"

    invoke-virtual {p1, v0, v1, v2, v3}, Lcom/snowplowanalytics/snowplow/tracker/payload/TrackerPayload;->addMap(Ljava/util/Map;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/String;)V

    :cond_1
    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->TAG:Ljava/lang/String;

    const-string v1, "Adding new payload to event storage: %s"

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    aput-object p1, v2, v3

    invoke-static {v0, v1, v2}, Lcom/snowplowanalytics/snowplow/tracker/utils/Logger;->v(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->emitter:Lcom/snowplowanalytics/snowplow/tracker/Emitter;

    invoke-virtual {v0, p1}, Lcom/snowplowanalytics/snowplow/tracker/Emitter;->add(Lcom/snowplowanalytics/snowplow/tracker/payload/Payload;)V

    return-void
.end method

.method public static close()V
    .locals 1

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    if-eqz v0, :cond_0

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->pauseSessionChecking()V

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->getEmitter()Lcom/snowplowanalytics/snowplow/tracker/Emitter;

    move-result-object v0

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/Emitter;->shutdown()V

    const/4 v0, 0x0

    sput-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    :cond_0
    return-void
.end method

.method private getFinalContext(Ljava/util/List;Ljava/lang/String;)Lcom/snowplowanalytics/snowplow/tracker/payload/SelfDescribingJson;
    .locals 3

    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionContext:Z

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->trackerSession:Lcom/snowplowanalytics/snowplow/tracker/Session;

    invoke-virtual {v0, p2}, Lcom/snowplowanalytics/snowplow/tracker/Session;->getSessionContext(Ljava/lang/String;)Lcom/snowplowanalytics/snowplow/tracker/payload/SelfDescribingJson;

    move-result-object v0

    invoke-interface {p1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    :cond_0
    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->geoLocationContext:Z

    if-eqz v0, :cond_1

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->context:Landroid/content/Context;

    invoke-static {v0}, Lcom/snowplowanalytics/snowplow/tracker/utils/Util;->getGeoLocationContext(Landroid/content/Context;)Lcom/snowplowanalytics/snowplow/tracker/payload/SelfDescribingJson;

    move-result-object v0

    invoke-interface {p1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    :cond_1
    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->mobileContext:Z

    if-eqz v0, :cond_2

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->context:Landroid/content/Context;

    invoke-static {v0}, Lcom/snowplowanalytics/snowplow/tracker/utils/Util;->getMobileContext(Landroid/content/Context;)Lcom/snowplowanalytics/snowplow/tracker/payload/SelfDescribingJson;

    move-result-object v0

    invoke-interface {p1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    :cond_2
    invoke-interface {p1}, Ljava/util/List;->size()I

    move-result v0

    if-nez v0, :cond_3

    const/4 v0, 0x0

    :goto_0
    return-object v0

    :cond_3
    new-instance v1, Ljava/util/LinkedList;

    invoke-direct {v1}, Ljava/util/LinkedList;-><init>()V

    invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v2

    :cond_4
    :goto_1
    invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_5

    invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/snowplowanalytics/snowplow/tracker/payload/SelfDescribingJson;

    if-eqz v0, :cond_4

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/payload/SelfDescribingJson;->getMap()Ljava/util/Map;

    move-result-object v0

    invoke-interface {v1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_1

    :cond_5
    new-instance v0, Lcom/snowplowanalytics/snowplow/tracker/payload/SelfDescribingJson;

    const-string v2, "iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1"

    invoke-direct {v0, v2, v1}, Lcom/snowplowanalytics/snowplow/tracker/payload/SelfDescribingJson;-><init>(Ljava/lang/String;Ljava/lang/Object;)V

    goto :goto_0
.end method

.method public static init(Lcom/snowplowanalytics/snowplow/tracker/Tracker;)Lcom/snowplowanalytics/snowplow/tracker/Tracker;
    .locals 1

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    if-nez v0, :cond_0

    sput-object p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->resumeSessionChecking()V

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->getEmitter()Lcom/snowplowanalytics/snowplow/tracker/Emitter;

    move-result-object v0

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/Emitter;->flush()V

    :cond_0
    invoke-static {}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->instance()Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    move-result-object v0

    return-object v0
.end method

.method public static instance()Lcom/snowplowanalytics/snowplow/tracker/Tracker;
    .locals 2

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    if-nez v0, :cond_0

    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "FATAL: Tracker must be initialized first!"

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_0
    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->getApplicationCrash()Z

    move-result v0

    if-eqz v0, :cond_1

    invoke-static {}, Ljava/lang/Thread;->getDefaultUncaughtExceptionHandler()Ljava/lang/Thread$UncaughtExceptionHandler;

    move-result-object v0

    instance-of v0, v0, Lcom/snowplowanalytics/snowplow/tracker/tracker/ExceptionHandler;

    if-nez v0, :cond_1

    new-instance v0, Lcom/snowplowanalytics/snowplow/tracker/tracker/ExceptionHandler;

    invoke-direct {v0}, Lcom/snowplowanalytics/snowplow/tracker/tracker/ExceptionHandler;-><init>()V

    invoke-static {v0}, Ljava/lang/Thread;->setDefaultUncaughtExceptionHandler(Ljava/lang/Thread$UncaughtExceptionHandler;)V

    :cond_1
    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->spTracker:Lcom/snowplowanalytics/snowplow/tracker/Tracker;

    return-object v0
.end method


# virtual methods
.method public getAppId()Ljava/lang/String;
    .locals 1

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->appId:Ljava/lang/String;

    return-object v0
.end method

.method public getApplicationCrash()Z
    .locals 1

    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->applicationCrash:Z

    return v0
.end method

.method public getBase64Encoded()Z
    .locals 1

    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->base64Encoded:Z

    return v0
.end method

.method public getDataCollection()Z
    .locals 1

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->dataCollection:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z

    move-result v0

    return v0
.end method

.method public getEmitter()Lcom/snowplowanalytics/snowplow/tracker/Emitter;
    .locals 1

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->emitter:Lcom/snowplowanalytics/snowplow/tracker/Emitter;

    return-object v0
.end method

.method public getLifecycleEvents()Z
    .locals 1

    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->lifecycleEvents:Z

    return v0
.end method

.method public getLogLevel()Lcom/snowplowanalytics/snowplow/tracker/utils/LogLevel;
    .locals 1

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->level:Lcom/snowplowanalytics/snowplow/tracker/utils/LogLevel;

    return-object v0
.end method

.method public getNamespace()Ljava/lang/String;
    .locals 1

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->namespace:Ljava/lang/String;

    return-object v0
.end method

.method public getPlatform()Lcom/snowplowanalytics/snowplow/tracker/DevicePlatforms;
    .locals 1

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->devicePlatform:Lcom/snowplowanalytics/snowplow/tracker/DevicePlatforms;

    return-object v0
.end method

.method public getSession()Lcom/snowplowanalytics/snowplow/tracker/Session;
    .locals 1

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->trackerSession:Lcom/snowplowanalytics/snowplow/tracker/Session;

    return-object v0
.end method

.method public getSubject()Lcom/snowplowanalytics/snowplow/tracker/Subject;
    .locals 1

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->subject:Lcom/snowplowanalytics/snowplow/tracker/Subject;

    return-object v0
.end method

.method public getThreadCount()I
    .locals 1

    iget v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->threadCount:I

    return v0
.end method

.method public getTrackerVersion()Ljava/lang/String;
    .locals 1

    invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    const-string v0, "andr-0.6.1"

    return-object v0
.end method

.method public pauseEventTracking()V
    .locals 3

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->dataCollection:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v1, 0x1

    const/4 v2, 0x0

    invoke-virtual {v0, v1, v2}, Ljava/util/concurrent/atomic/AtomicBoolean;->compareAndSet(ZZ)Z

    move-result v0

    if-eqz v0, :cond_0

    invoke-virtual {p0}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->pauseSessionChecking()V

    invoke-virtual {p0}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->getEmitter()Lcom/snowplowanalytics/snowplow/tracker/Emitter;

    move-result-object v0

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/Emitter;->shutdown()V

    :cond_0
    return-void
.end method

.method public pauseSessionChecking()V
    .locals 3

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionExecutor:Ljava/util/concurrent/ScheduledExecutorService;

    if-eqz v0, :cond_0

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->TAG:Ljava/lang/String;

    const-string v1, "Session checking has been paused."

    const/4 v2, 0x0

    new-array v2, v2, [Ljava/lang/Object;

    invoke-static {v0, v1, v2}, Lcom/snowplowanalytics/snowplow/tracker/utils/Logger;->d(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionExecutor:Ljava/util/concurrent/ScheduledExecutorService;

    invoke-interface {v0}, Ljava/util/concurrent/ScheduledExecutorService;->shutdown()V

    const/4 v0, 0x0

    sput-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionExecutor:Ljava/util/concurrent/ScheduledExecutorService;

    :cond_0
    return-void
.end method

.method public resumeEventTracking()V
    .locals 3

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->dataCollection:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v1, 0x0

    const/4 v2, 0x1

    invoke-virtual {v0, v1, v2}, Ljava/util/concurrent/atomic/AtomicBoolean;->compareAndSet(ZZ)Z

    move-result v0

    if-eqz v0, :cond_0

    invoke-virtual {p0}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->resumeSessionChecking()V

    invoke-virtual {p0}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->getEmitter()Lcom/snowplowanalytics/snowplow/tracker/Emitter;

    move-result-object v0

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/Emitter;->flush()V

    :cond_0
    return-void
.end method

.method public resumeSessionChecking()V
    .locals 7

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionExecutor:Ljava/util/concurrent/ScheduledExecutorService;

    if-nez v0, :cond_0

    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionContext:Z

    if-eqz v0, :cond_0

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->TAG:Ljava/lang/String;

    const-string v1, "Session checking has been resumed."

    const/4 v2, 0x0

    new-array v2, v2, [Ljava/lang/Object;

    invoke-static {v0, v1, v2}, Lcom/snowplowanalytics/snowplow/tracker/utils/Logger;->d(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V

    iget-object v2, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->trackerSession:Lcom/snowplowanalytics/snowplow/tracker/Session;

    invoke-static {}, Ljava/util/concurrent/Executors;->newSingleThreadScheduledExecutor()Ljava/util/concurrent/ScheduledExecutorService;

    move-result-object v0

    sput-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionExecutor:Ljava/util/concurrent/ScheduledExecutorService;

    sget-object v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionExecutor:Ljava/util/concurrent/ScheduledExecutorService;

    new-instance v1, Lcom/snowplowanalytics/snowplow/tracker/Tracker$2;

    invoke-direct {v1, p0, v2}, Lcom/snowplowanalytics/snowplow/tracker/Tracker$2;-><init>(Lcom/snowplowanalytics/snowplow/tracker/Tracker;Lcom/snowplowanalytics/snowplow/tracker/Session;)V

    iget-wide v2, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionCheckInterval:J

    iget-wide v4, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionCheckInterval:J

    iget-object v6, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->timeUnit:Ljava/util/concurrent/TimeUnit;

    invoke-interface/range {v0 .. v6}, Ljava/util/concurrent/ScheduledExecutorService;->scheduleAtFixedRate(Ljava/lang/Runnable;JJLjava/util/concurrent/TimeUnit;)Ljava/util/concurrent/ScheduledFuture;

    :cond_0
    return-void
.end method

.method public setEmitter(Lcom/snowplowanalytics/snowplow/tracker/Emitter;)V
    .locals 1

    invoke-virtual {p0}, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->getEmitter()Lcom/snowplowanalytics/snowplow/tracker/Emitter;

    move-result-object v0

    invoke-virtual {v0}, Lcom/snowplowanalytics/snowplow/tracker/Emitter;->shutdown()V

    iput-object p1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->emitter:Lcom/snowplowanalytics/snowplow/tracker/Emitter;

    return-void
.end method

.method public setLifecycleHandler(Landroid/app/Activity;)V
    .locals 2

    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->lifecycleEvents:Z

    if-nez v0, :cond_0

    iget-boolean v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->sessionContext:Z

    if-eqz v0, :cond_1

    :cond_0
    sget v0, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v1, 0xe

    if-lt v0, v1, :cond_1

    new-instance v0, Lcom/snowplowanalytics/snowplow/tracker/tracker/LifecycleHandler;

    invoke-direct {v0}, Lcom/snowplowanalytics/snowplow/tracker/tracker/LifecycleHandler;-><init>()V

    invoke-virtual {p1}, Landroid/app/Activity;->getApplication()Landroid/app/Application;

    move-result-object v1

    invoke-virtual {v1, v0}, Landroid/app/Application;->registerActivityLifecycleCallbacks(Landroid/app/Application$ActivityLifecycleCallbacks;)V

    invoke-virtual {p1, v0}, Landroid/app/Activity;->registerComponentCallbacks(Landroid/content/ComponentCallbacks;)V

    :cond_1
    return-void
.end method

.method public setPlatform(Lcom/snowplowanalytics/snowplow/tracker/DevicePlatforms;)V
    .locals 0

    iput-object p1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->devicePlatform:Lcom/snowplowanalytics/snowplow/tracker/DevicePlatforms;

    return-void
.end method

.method public setSubject(Lcom/snowplowanalytics/snowplow/tracker/Subject;)V
    .locals 0

    iput-object p1, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->subject:Lcom/snowplowanalytics/snowplow/tracker/Subject;

    return-void
.end method

.method public track(Lcom/snowplowanalytics/snowplow/tracker/events/Event;)V
    .locals 1

    iget-object v0, p0, Lcom/snowplowanalytics/snowplow/tracker/Tracker;->dataCollection:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z

    move-result v0

    if-nez v0, :cond_0

    :goto_0
    return-void

    :cond_0
    new-instance v0, Lcom/snowplowanalytics/snowplow/tracker/Tracker$1;

    invoke-direct {v0, p0, p1}, Lcom/snowplowanalytics/snowplow/tracker/Tracker$1;-><init>(Lcom/snowplowanalytics/snowplow/tracker/Tracker;Lcom/snowplowanalytics/snowplow/tracker/events/Event;)V

    invoke-static {v0}, Lcom/snowplowanalytics/snowplow/tracker/Executor;->execute(Ljava/lang/Runnable;)V

    goto :goto_0
.end method
